﻿using ClusteringProblem.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClusteringProblem.Maths.Metrics
{
    /// <summary>
    /// Miara Manhattan (miejska)
    /// </summary>
    public class ManhattanDistance : IDistance
    {
        public double ComputeDistance(IVectorType x, IVectorType y)
        {
            int vectorLength = x.Vector.Length;
            double result = 0.0;

            for (int i = 0; i < vectorLength; ++i)
            {
                result += Math.Abs(x.Vector[i] - y.Vector[i]);
            }

            return result;
        }
    }
}
